import User from "@/model/User"
import {getMineUserInfoAPI} from "@/views/user/userAPI"

export default {
  namespaced: true,
  state: {
    //只要登录了，这个User肯定有值
    user: null,
  },
  mutations: {
    setUser(state, user) {
      state.user = new User(user)
    },
  },
  actions: {
    getUserInfo({commit}) {
      return getMineUserInfoAPI().then(res => {
        commit('setUser', res.data)
      })
    }
  }
}

